import editsvc from "./service/editsvc";
import alignsvc from '../service/alignsvc.js'
import layoursvc from "../service/layoursvc";

import { LGXEnums } from "../common/sysenum";
import mapevent from "../common/mapevent";
import circlearrsvc from "./service/circlearrsvc";
import rectarrsvc from "./service/rectarrsvc";
import { GlobalVar } from "../common/globalvar";
import { ArrowKeyTranslateSvc } from "./service/arrowkeytranssvc";

class EditINTF {
    constructor(canvas) {
        this.m_pCanvas = canvas;
        this.m_pService = new editsvc.EditSvc(canvas.getDataManager(), canvas.getOperStepService());
    }

    finishDrawMultiPosGraph() {
        let evt = this.m_pService.finishDrawMultiPosGraph();
        this.m_pCanvas.setMapWorkMode(LGXEnums.LGXWorkMode.ModifyMode);
        if (evt) {
            this.m_pCanvas.notifyEvents(evt);
        }
    }
    modifyGraphDataByStru(info, needEditEventFlag) {
        console.log("modify grapg by ");
        let rst = 0;
        if (info) {
            rst = this.m_pService.modifyGraphDataByStru(info);
        }
        this.m_pCanvas.rePaint(1);
        return rst;
    }

    modifyGraphStyle(cmd) {
        this.m_pService.modifyGraphStyle(cmd);
        this.m_pCanvas.rePaint(1);
    }

    rotate(degree) {
        this.m_pService.rotate(degree);
        this.m_pCanvas.rePaint(1);
    }

    delete() {
        this.m_pService.delete();
        this.m_pCanvas.rePaint(1);
    }


    //1,锁定,0--解锁
    lockGraph(id, lockflag, lockKind) {
        this.m_pService.lockGraph(id, lockflag, lockKind);
        this.m_pCanvas.rePaint(1);
    }

    closeInDrawingPolyline() {
        let evt = this.m_pService.closeInDrawingPolyline();
        this.m_pCanvas.rePaint(1);
        if (evt) {
            this.m_pCanvas.notifyEvents(evt);
        }
    }

    align(kind) {
        let svc = new alignsvc.AlignGraphSvc(this.m_pCanvas.getDataManager());
        svc.align(kind);
        this.m_pCanvas.rePaint(1);
    }

    combine() {
        this.m_pService.combine();
        this.m_pCanvas.rePaint(1);
    }


    modifyCoordDatas(cmd) {
        this.m_pService.modifyCoordDatas(cmd);
        this.m_pCanvas.rePaint(1);
    }

    layout(kind) {
        let svc = new layoursvc.LayoutGraphSvc(this.m_pCanvas.getDataManager());
        svc.layout(kind);
        this.m_pCanvas.rePaint(1);
    }

    setArcPlotMode(mode) {
        GlobalVar.arcPlotMode = mode;
    }

    modifyDrawingGraphByCMD(graphType, cmd) {
        let rst = this.m_pService.modifyDrawingGraphByCMD(graphType, cmd);
        if (rst && rst.finish) {
            this.m_pCanvas.setMapWorkMode(LGXEnums.LGXWorkMode.ModifyMode);
        }
        this.m_pCanvas.rePaint(1);
        return rst;
    }

    sendCMD2SubEditControler(subEditMode, cmd) {
        let rst = this.m_pService.sendCMD2SubEditControler(subEditMode, cmd);
        if (rst && rst.finish) {
            this.m_pCanvas.setMapWorkMode(LGXEnums.LGXWorkMode.ModifyMode);
        }
        this.m_pCanvas.rePaint(1);
        return rst;
    }

    ringArray(cntDesc, count, angleSpan) {
        console.log("ringArray************************");
        let dataManger = this.m_pCanvas.getDataManager();
        let svc = new circlearrsvc.CircleArraySvc();
        let rst = svc.array(dataManger, cntDesc, count, angleSpan);
        this.m_pCanvas.rePaint(1);
        return rst;
    }

    rectArray(rowCount, rowGap, colCount, colGap) {
        console.log("rectArray************************");
        let dataManger = this.m_pCanvas.getDataManager();
        let svc = new rectarrsvc.RectArraySvc();
        let rst = svc.array(dataManger, rowCount, rowGap, colCount, colGap);
        this.m_pCanvas.rePaint(1);
        return rst;
    }
    setSymbolUnitMark(item) {
        return this.m_pService.setSymbolUnitMark(item);
    }

    modifySymbolUnitCtrlInfo(unitCtlInfo) {
        return this.m_pService.modifySymbolUnitCtrlInfo(unitCtlInfo);
    }

    arrowKeyTranslate(keycode) {
        let dataManger = this.m_pCanvas.getDataManager();
        ArrowKeyTranslateSvc.actToArrowKey(dataManger, keycode);
        this.m_pCanvas.rePaint(1);
    }


    explode(gid) {
        this.m_pService.explode(gid);
        this.m_pCanvas.rePaint(1);
    }
}

export default { EditINTF }